import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class StudentTest {
    public static void main(String[] args) {
        Student[] s = new Student[10];



        s[0] = new Student("A", "001", 300);
        s[1] = new Student("B", "002", 342);
        s[2] = new Student("C", "003", 214);
        s[3] = new Student("D", "004", 432);
        s[4] = new Student("E", "005", 343);
        s[5] = new Student("F", "006", 312);
        s[6] = new Student("G", "007", 384);
        s[7] = new Student("H", "008", 387);
        s[8] = new Student("I", "009", 398);
        s[9] = new Student("G", "010", 234);

        for (int i = 0; i < s.length; i++) {
            for (int j = i + 1; j < s.length; j++){
                if (s[i].getSumOfScore() > s[j].getSumOfScore()) {
                    Student S = new Student();
                    S = s[i];
                    s[i] = s[j];
                    s[j] = S;
                }
            }
        }

        Collection con = new ArrayList();

        for (int i = 0; i < s.length; i++) {
            con.add(s[i]);
        }

        Iterator iterator = con.iterator();

        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}

class Student {
    private String name;

    private String id;

    private int sumOfScore;

    public Student() {
        this(" ", " ", 0);
    }

    public Student(String name, String id, int sumOfScore) {
        this.name = name;
        this.id = id;
        this.sumOfScore = sumOfScore;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getSumOfScore() {
        return sumOfScore;
    }

    public void setSumOfScore(int sumOfScore) {
        this.sumOfScore = sumOfScore;
    }

    public String toString() {
        return "{ 姓名: " + this.getName() + ", 学号: " + this.getId() + ", 总成绩: " + this.getSumOfScore() + " }";
    }
}